package com.learn.springbootlogback;

import jakarta.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

/**
 * @author: liyf
 * @create: 2025-03-23 21:19
 **/
@Component
public class SpringEnvironmentDemo {

    private static final Logger logger = LoggerFactory.getLogger(SpringEnvironmentDemo.class);

    private final Environment environment;

    public SpringEnvironmentDemo(Environment environment) {
        this.environment = environment;
    }

    @PostConstruct
    public void print() {
        logger.info("spring.application.name: " + environment.getProperty("spring.application.name"));
        logger.info("logging.file.name: " + environment.getProperty("logging.file.name"));
        logger.info("logging.file.path: " + environment.getProperty("logging.file.path"));
        logger.info("logging.logback.rollingpolicy.file-name-pattern: " + environment.getProperty("logging.logback.rollingpolicy.file-name-pattern"));
    }
}
